package cn.com.darly.videoandroidpm.ui.artamuse;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.darly.common.ToastApp;
import com.darly.dview.framework.ContentBinder;
import com.darly.dview.framework.ViewsBinder;
import com.darly.dview.widget.header.TitleView;

import java.util.List;

import cn.com.darly.videoandroidpm.R;
import cn.com.darly.videoandroidpm.base.BaseActivity;
import cn.com.darly.videoandroidpm.bean.FragmentMainInfo;
import cn.com.darly.videoandroidpm.ui.adapter.PublishedAmuseAdapter;
import cn.com.darly.videoandroidpm.ui.biz.PublishedAmuseListener.PublishedAmuseInterface;
import cn.com.darly.videoandroidpm.ui.presenter.PublishedAmusePresenter;

/**
 * @author Darly/张宇辉/2018/5/11 14:36
 * @version 1.0/cn.com.darly.videoandroidpm.ui.artamuse
 */
@ContentBinder(R.layout.activity_published_amuse)
public class PublishedAmuseActivity extends BaseActivity implements OnClickListener,PublishedAmuseInterface{
    @ViewsBinder(R.id.id_base_title)
    public TitleView id_base_title;

    @ViewsBinder(R.id.id_publish_anim)
    LinearLayout id_publish_anim;
    @ViewsBinder(R.id.id_publish_userlist)
    ListView id_publish_userlist;

    @ViewsBinder(R.id.id_publish_sera)
    LinearLayout id_publish_sera;
    @ViewsBinder(R.id.id_publish_checker_no)
    TextView id_publish_checker_no;

    private PublishedAmuseAdapter adapter;
    private PublishedAmusePresenter presenter;
    @Override
    protected void initView(Bundle savedInstanceState) {
        id_base_title.setTitle("我的话题");
        id_publish_anim.setAnimation(AnimationUtils.loadAnimation(this, R.anim.login_up));
        presenter = new PublishedAmusePresenter(this);
        presenter.published();
    }

    @Override
    protected void loadData() {
        adapter = new PublishedAmuseAdapter(null,R.layout.item_fragment_main,this);
        id_publish_userlist.setAdapter(adapter);
    }

    @Override
    protected void initListener() {
        id_base_title.setLeftBackOneListener(R.mipmap.ic_title_back,this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.title_view_back_img:
                finish();
                break;
        }
    }

    @Override
    public void onPublishedAmuseSuccess(List<FragmentMainInfo> data) {
        if (data!=null&&data.size()>0){
            adapter.setData(data);
            id_publish_anim.setVisibility(View.VISIBLE);
            id_publish_sera.setVisibility(View.GONE);
        }else {
            id_publish_anim.setVisibility(View.GONE);
            id_publish_sera.setVisibility(View.VISIBLE);
        }
    }

    @Override
    public void onPublishedAmuseFailed(String info) {
        ToastApp.showToast(info);
    }

    @Override
    public void setDisableClick() {

    }

    @Override
    public void setEnableClick() {

    }
}
